package com.wuhunyu.controller;


import com.wuhunyu.commonutils.result.CommonResult;
import com.wuhunyu.entities.vo.UserLogin;
import com.wuhunyu.entities.vo.UserRegister;
import com.wuhunyu.service.UcenterMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.yaml.snakeyaml.events.Event;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * <p>
 * 会员表 前端控制器
 * </p>
 *
 * @author wuhunyu
 * @since 2021-01-23
 */
@RestController
@RequestMapping("/userCenterMember")
//@CrossOrigin
public class UcenterMemberController {

    @Autowired
    private UcenterMemberService ucenterMemberService;

    @PostMapping("/login")
    public CommonResult login(@RequestBody(required = true) UserLogin userLogin) {
        return ucenterMemberService.login(userLogin);
    }

    @PostMapping("/register")
    public CommonResult register(@RequestBody(required = true) UserRegister userRegister) {
        return ucenterMemberService.register(userRegister);
    }

    @PostMapping("/selectMemberInfo")
    public CommonResult selectMemberInfo(HttpServletRequest request) {
        System.out.println("request=" + request);
        return ucenterMemberService.selectMemberInfo(request);
    }

    @PostMapping("/selectMemberInfoById")
    public CommonResult selectMemberInfo(@RequestBody String id) {
        return ucenterMemberService.selectMemberInfo(id);
    }

    @PostMapping("/countRegister/{date}")
    public CommonResult countRegister(@PathVariable("date") String date) {
        return ucenterMemberService.countRegister(date);
    }

}

